﻿using UnityEngine;
using System.Collections;

/*
 * 玩家操作的军队
 */

public enum EUIAction
{
	eSelSquare,
}

public class UIPlayerMessage : System.EventArgs
{
	public EUIAction playerAct;
}

public class PlayerForces : MonoBehaviour {

	public System.EventHandler<UIPlayerMessage> evtUIHandlerMsg;

	public Square sqr1;
	public Square sqr2;
	public Square sqr3;

	public Square[] forces;

	private Square selSquare;
	public Square CurSelSquare
	{
		get {return selSquare;}
		set {selSquare = value;}
	}

	// Use this for initialization
	void Start () {
		forces = new Square[3];

		forces [0] = sqr1;
		forces [1] = sqr2;
		forces [2] = sqr3;

		foreach (Square sq in forces)
		{
			sq.control.selSquare += OnOneSquareSelect;
		}
		
		CurSelSquare = forces[0];
	}
	
	// Update is called once per frame
	void Update () {
		
	}


	void OnOneSquareSelect(object sender, SelectSquareArgs args)
	{
		selSquare = sender as Square;

		UIPlayerMessage msg = new UIPlayerMessage();
		msg.playerAct = EUIAction.eSelSquare;

		if (null != evtUIHandlerMsg)
			evtUIHandlerMsg (this, msg);
	}
}
